<template>
	<view>
		<page-head headTitle="钱包" :returnButton="true" @clickLeftReturn="clickLeftReturn"></page-head>
		<view class="m-t9">
			<view>
				<view class="scan-mt bg-pic flex align-center justify-content">
					<view>
						<view class="width flex align-center justify-content">
							<text class="line-height"><text class="store-size font-weight">{{accountInfo.balance}}</text><text>元</text></text>
						</view>
						<navigator url="../withdraw/withdraw">
							<view class="width flex align-center justify-content">
								<text class="flash align-center">去提现<text class="iconfont icon-dibudaohanglan-"></text></text>
							</view>
						</navigator>
					</view>
				</view>	
				<view class="p-l-r m-t6" v-if="logs>0">
					<view v-for="(item,index) in accountInfo.logs" :key="index" class="flex justify-between align-center border-botton p-t-b1">
						<view>
							<view>
								<text class="fs-3">{{item.remark}}</text>
							</view>
							<text class="fs-24">{{item.date}}</text>
						</view>
						<text class="fs-3 color-orange">{{item.symbol}}{{item.change}}</text>
					</view>
				</view>	
				<!-- 占位图 -->
				<view v-else class="flex justify-content m-t flex-wrap">
					<image src="/static/images/order_none.png" class="order-icon">
				</view>
			</view>	
		</view>	
	</view>
</template>

<script>
import pageHead from '@/components/common/page-head.vue'
	export default {
		components:{
			pageHead
		},
		data() {
			return {
				accountInfo:{},
				logs:0
			}
		},
		onLoad() {
			this.account();
		},
		methods: {
			clickLeftReturn(){
				const pages = getCurrentPages() ;
				if(pages.length >1) {
					uni.navigateBack({
						delta: 1
					});
				}else{
					//返回上一页失败后强制回到首页
					uni.redirectTo({
						url: '../index/index'
					})
				}
			},
			account(){
				this.$myRequest({
					method:'POST',
					url:'/api/guide/account'
				}).then(res=>{
					console.log(res);
					if(res.data.code == 1){
						this.accountInfo = res.data.data;
						this.logs = res.data.data.logs.length;
					}	
				})
			}
		}
	}
</script>

<style>
page{background-color: #FFFFFF;}
.bg-pic{height: 340rpx; background-image: url(../../../static/images/store.png);background-repeat:no-repeat;background-size:100% 100%;-moz-background-size:100% 100%;}
.scan-money{width: 428rpx;}
.store-size{font-size: 70rpx;}
</style>
